<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <form id="myForm">
        <input type="text" name="email_or_mobile"/>
        <input type="password" name="password" />
        <input type="checkbox" name="remember_me" checked />

        <button id="submit" type="submit">登录-submit</button>
        
    </form>
    <script src="./lib/form-serialize.js"></script>
    <script>
        document.querySelector('#submit').addEventListener('click', (e) => {
            // 阻止按钮的默认行为
            e.preventDefault()
            // 
            // 使用form-serialize 快速拿到表单元素的值
            const myForm = document.querySelector('#myForm')
            // 方式1
            console.log( serialize(myForm) )
            // 返回一个查询字符串：属性名1=值1&属性名2=值2&属性名3=值3

            // 方式2
            console.log( serialize(myForm, {hash: true}) )
            // 返回一个对象

            
        })
    </script>
</body>
</html>